import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { coreKhlxrListData } from '/@/api/bas/cus/coreKhlxr';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('联系人选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 100,
  schemas: [
    {
      label: t('联系人编码'),
      field: 'khlxrLxrbm',
      component: 'Input',
    },
    {
      label: t('联系人名称'),
      field: 'khlxrLxrmc',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('联系人编码'),
    dataIndex: 'khlxrLxrbm',
    key: 'a.khlxr_lxrbm',
    sorter: true,
    width: 130,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('联系人名称'),
    dataIndex: 'khlxrLxrmc',
    key: 'a.khlxr_lxrmc',
    sorter: true,
    width: 180,
    align: 'left',
  },
  {
    title: t('部门'),
    dataIndex: 'khlxrBm',
    key: 'a.khlxr_bm',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('联系电话'),
    dataIndex: 'khlxrLxdh',
    key: 'a.khlxr_lxdh',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('默认联系人'),
    dataIndex: 'khlxrMrlxr',
    key: 'a.khlxr_mrlxr',
    dictType: 'sys_yes_no',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('客户名称'),
    dataIndex: 'basCus.khdaDwqc',
    key: 'a.parent_id',
    sorter: true,
    width: 230,
    align: 'left',
  },
  {
    title: t('状态'),
    dataIndex: 'status',
    key: 'a.status',
    sorter: true,
    width: 80,
    align: 'center',
    dictType: 'sys_search_status',
  },
  {
    title: t('备注'),
    dataIndex: 'remarks',
    key: 'a.remarks',
    sorter: true,
    width: 130,
    align: 'left',
  },
];

const tableProps: BasicTableProps = {
  api: coreKhlxrListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'khlxrLxrbm',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'khlxrLxrbm',
  itemName: 'khlxrLxrmc',
  isShowCode: true,
};
